#-----------------------------------
# Name: Chris Spooner
# Project Madlibs.py
# Period: 1
# Start Date: 9/18/2013
# Last Revision Date: 9/18/2013
# Version: 1.0.0
#-----------------------------------
import os

swearList = [  "anus",
               "arse"
               "arsehole",
               "ass",
               "ass-hat",
               "ass-jabber",
               "ass-pirate",
               "assbag",
               "assbandit",
               "assbanger",
               "assbite",
               "assclown",
               "asscock",
               "asscracker",
               "asses",
               "assface",
               "assfuck",
               "assfucker",
               "assgoblin",
               "asshat",
               "asshead",
               "asshole",
               "asshopper",
               "assjacker",
               "asslick",
               "asslicker",
               "assmonkey",
               "assmunch",
               "assmuncher",
               "assnigger",
               "asspirate",
               "assshit",
               "assshole",
               "asssucker",
               "asswad",
               "asswipe",
               "axwound"
               "bampot"
               "bastard",
               "beaner",
               "bitch",
               "bitchass",
               "bitches",
               "bitchtits",
               "bitchy",
               "blow job",
               "bollocks",
               "boner",
               "brotherfucker",
               "bullshit",
               "bumblefuck",
               "butt plug",
               "butt-pirate",
               "buttfucka",
               "buttfucker",
               "camel toe",
               "carpetmuncher",
               "chesticle",
               "chinc",
               "chink",
               "choad",
               "chode",
               "clit",
               "clitface",
               "clitfuck",
               "clusterfuck",
               "cock",
               "cockass",
               "cockbite",
               "cockburger",
               "cockface",
               "cockfucker",
               "cockhead",
               "cockjockey",
               "cockknoker",
               "cockmaster",
               "cockmongler",
               "cockmongruel",
               "cockmonkey",
               "cockmuncher",
               "cocknose",
               "cocknugget",
               "cockshit",
               "cocksmith",
               "cocksmoke",
               "cocksmoker",
               "cocksniffer",
               "cocksucker",
               "cockwaffle",
               "coochie",
               "coochy",
               "coon",
               "cooter",
               "cracker",
               "cum",
               "cumbubble",
               "cumdumpster",
               "cumguzzler",
               "cumjockey",
               "cumslut",
               "cumtart",
               "cunnie",
               "cunnilingus",
               "cunt",
               "cuntass",
               "cuntface",
               "cunthole",
               "cuntlicker",
               "cuntrag",
               "cuntslut",
               "damn",
               "deggo",
               "dick",
               "dick-sneeze",
               "dickbag",
               "dickbeaters",
               "dickface",
               "dickfuck",
               "dickfucker",
               "dickhead",
               "dickhole",
               "dickjuice",
               "dickmilk",
               "dickmonger",
               "dicks",
               "dickslap",
               "dicksucker",
               "dicksucking",
               "dicktickler",
               "dickwad",
               "dickweasel",
               "dickweed",
               "dickwod",
               "dike",
               "dildo",
               "dipshit",
               "doochbag",
               "dookie",
               "douche",
               "douche-fag",
               "douchebag",
               "douchewaffle",
               "dumass",
               "dumb ass",
               "dumbfuck",
               "dumbshit",
               "dumshit",
               "dyke",
               "fag",
               "fagbag",
               "fagfucker",
               "faggit",
               "faggot",
               "faggotcock",
               "fagtard",
               "fatass",
               "fellatio",
               "feltch",
               "flamer",
               "fuck",
               "fuckass",
               "fuckbag",
               "fuckboy",
               "fuckbrain",
               "fuckbutt",
               "fuckbutter",
               "fucked",
               "fucker",
               "fuckersucker",
               "fuckface",
               "fuckhead",
               "fuckhole",
               "fuckin",
               "fucking",
               "fucknut",
               "fucknutt",
               "fuckoff",
               "fucks",
               "fuckstick",
               "fucktard",
               "fucktart",
               "fuckup",
               "fuckwad",
               "fuckwit",
               "fuckwitt",
               "fudgepacker",
               "gay",
               "gayass",
               "gaybob",
               "gaydo",
               "gayfuck",
               "gayfuckist",
               "gaylord",
               "gaytard",
               "gaywad",
               "goddamn",
               "goddamnit",
               "gooch",
               "gook",
               "gringo",
               "guido",
               "handjob",
               "hard on",
               "hell",
               "ho",
               "hoe",
               "homo",
               "homodumbshit",
               "honkey",
               "humping",
               "jackass",
               "jagoff",
               "jap",
               "jerk off",
               "jerkass",
               "jigaboo",
               "jizz",
               "jungle bunny",
               "junglebunny",
               "kike",
               "kooch",
               "kraut",
               "kunt",
               "kyke",
               "lameass",
               "lardass",
               "lesbian",
               "lesbo",
               "lezzie",
               "mcfagget",
               "mick",
               "minge",
               "mothafucka",
               "mothafuckin",
               "motherfucker",
               "motherfucking",
               "muff",
               "muffdiver",
               "munging",
               "negro",
               "nigaboo",
               "nigga",
               "nigger",
               "niggers",
               "niglet",
               "nut sack",
               "nutsack",
               "paki",
               "panooch",
               "pecker",
               "peckerhead",
               "penis",
               "penisbanger",
               "penisfucker",
               "penispuffer",
               "piss",
               "pissed",
               "pissed off",
               "pissflaps",
               "polesmoker",
               "pollock",
               "poon",
               "poonani",
               "poonany",
               "poontang",
               "porch monkey",
               "porchmonkey",
               "prick",
               "punanny",
               "punta",
               "pussies",
               "pussy",
               "pussylicking",
               "puto",
               "queef",
               "queer",
               "queerbait",
               "queerhole",
               "renob",
               "rimjob",
               "ruski",
               "sand nigger",
               "sandnigger",
               "schlong",
               "scrote",
               "shit",
               "shitass",
               "shitbag",
               "shitbagger",
               "shitbrains",
               "shitbreath",
               "shitcanned",
               "shitcunt",
               "shitdick",
               "shitface",
               "shitfaced",
               "shithead",
               "shithole",
               "shithouse",
               "shitspitter",
               "shitstain",
               "shitter",
               "shittiest",
               "shitting",
               "shitty",
               "shiz",
               "shiznit",
               "skank",
               "skeet",
               "skullfuck",
               "slut",
               "slutbag",
               "smeg",
               "snatch",
               "spic",
               "spick",
               "splooge",
               "spook",
               "suckass",
               "tard",
               "testicle",
               "thundercunt",
               "tit",
               "titfuck",
               "tits",
               "tittyfuck",
               "twat",
               "twatlips",
               "twats",
               "twatwaffle",
               "wank",
               "wankjob",
               "wetback",
               "whore",
               "whorebag",
               "whoreface",
               "wop",]

bgColor = '0'
txtColor = 'F'

def getMenuOption(maxOptions):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter a number or S or Q> ")
        option = option.upper()
        if option == 'S':
            goodOption = True
        elif option == 'Q' :
            goodOption = True
        elif option == "":
            pass
        else:
            isNum = True
            for character in option:
                if character not in "0123456789":
                    isNum = False
            if isNum:
                if int(option) <= 0:
                    isNum = False
                elif int(option) > maxOptions:
                    isNum = False
            if isNum:
                goodOption = True
            else:
                print "It would be fan-freaking-tastic if you entered a number, S or Q."
        if not goodOption:
            print "Do you not know what a number is? You may want to go back to preschool or try again and type a valid number. "
    return option

def menu():
    print "Welcome to Madlibs"
    print "Please Select an Option:"
    print " [1] The Runaway Tire"
    print " [2] The Legen... Wait For It... Dary Story!"
    print " [3] Zombies At The Mall"
    print " [S] Settings"
    print " [Q] Quit"
    option = getMenuOption(3)
    return option

def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearList:
            isNum = False
            for digit in word:
                if digit in "0123456789":
                    isNum = True
            if not isNum:
                goodWord = True
            else:
                print "Words don't have digits!"
        else:
            print "That isn't a valid word!" 
        if not goodWord:
            print "Try again!"
    return word

def getNumber(prompt, min = "", max = ""):
        num = ""
        goodNumber = False
        while not goodNumber:
            num = raw_input(prompt)
            isNum = True
            for digit in num:
                if digit not in ".0123456789":
                    isNum = False
            if isNum:
                if min != "":
                    if float(num) < min:
                        isNum = False
                if max != "":
                    if float(num) > max:
                        isNum = False
            if isNum:
                goodNumber = True
            else:
                print "Please enter a valid number"
        return num
                    
def getColor(prompt):
    colors = ["black",
              "blue",
              "green",
              "bright white",
              "light red",
              "red"]
    opt = ""
    goodColor = False
    while not goodColor:
        opt = raw_input(prompt)
        if opt.lower() in colors:
            goodColor = True
    if opt == "black":
        color = '0'
    elif opt == 'blue':
        color = '1'
    elif opt == 'green':
        color = '2'
    elif opt == 'bright white':
        color = 'F'
    elif opt == 'light red':
        color = 'C'
    elif opt == 'red':
        color = '4'
    return color
        
            
                    
def story1():
    place1 = getWord("Enter a town or city: ")
    verb1 = getWord("Enter an activity: ")
    adjective1 = getWord("Enter a describing word: ")
    name1 = getWord("Enter a male name: ")
    number = getNumber("Enter a number: ")
    name2 = getWord("Enter a name: ")
    object = getWord("Enter an object: ")
    adjective2 = getWord("Enter a describing word: ")
    story = "All was calm and quiet in "
    story += place1 + ". "
    story += "People were "
    story += verb1 + " "
    story += "around town like any other day. "
    story += "Then a young man turned his head and saw a "
    story += adjective1 + " "
    story += "tire rolling down the road. "
    story += "Not a single person in "
    story += place1 + " "
    story += "had the slightest idea where this tire came from. "
    story += "Some of the people started running after the tire to stop it from causing any major damage to the town. "
    story += "Before they could reach the tire it bounced over the curb and went right through Old Man "
    story += name1 + "'s "
    story += "hardware store window. "
    story += "It took "
    story += number + " "
    story += "people to clean up the mess in the hardware store. "
    story += name2 + " "
    story += "decided, instead of letting the tire go to waste they would take it home and make a "
    story += object + " out of it. "
    story += "To this day no one had the slightest idea where the tire had come from, but all would agree, it made for a "
    story += adjective2 + " "
    story += "story."
    
    print
    print formatString(story, 80, 20)
    print

def story2():
    name1 = getWord("Enter a male name: ")
    name2 = getWord("Enter another male name: ")
    number1 = getNumber("Enter a number: ")
    name3 = getWord("Enter new male name: ")
    number2 = getNumber("Enter a number that's at least three digits: ", 100)
    activity1 = getWord("Enter something you would do with your girlfriend in the past tense: ")
    animal = getWord("Enter an animal: ")
    name4 = getWord("Enter a male name: ")
    number3 = getNumber("Enter a number thats at least four digits: ", 1000)
    story = "It started out as an ordinary night at "
    story += name1 + "'s house. "
    story += "We were having a guys night so we decided to play poker. "
    story += "Somehow an argument started about who was the manliest guy there. To solve this dilemma we decided to tell manly stories about ourselves. "
    story += name2 + " started things off. 'I went down to the gym and started benching like "
    story += number1 + " pounds, wait no, no, like " 
    story += number1 + " people bro... like strippers. It was so sick. It was like no big deal, I got about 100 reps in. It was chill' "
    story += name3 + " got up and punched him in the face. "
    story += "He then sat back down to tell his story. "
    story += "'Oh yea, well this one time I did a 24 hour dungeon crawl using no armour, no magic and only a level one sword to beat "
    story += number2 + " fire dragons. Then I collected all their loot, bought a f***ing griffin, flew to Babe Island where I "
    story += activity1 + " all the babes on the island. On a school night. Epic!!' "
    story += name1 + " looks over and says 'NEEERRRRDDD!!' "
    story += name3 + " says, 'No, it was hella manly!' "
    story += name1 + " says, 'Anyway...' He looks across the table at a "
    story += animal + " 'So how about you forest assassin. Any interesting stories?' "
    story += "The " + animal + " started to tell his tale about being a samurai warrior and having to leave his family to fight a war. "
    story += name1 + " said, 'Awwww you're soooo cute. You're like a little bunny.' "
    story += "Then " + name4 + ", whom was a 76 year old man, started telling his story. "
    story += " 'I remember back in 1944 when we landed in Normandy.' "
    story += name1 + " rolls his eyes and says, 'Ugh, boring!' "
    story += "Then " + name1 + " says, 'I got you all beat! "
    story += "This morning I downed a gallon of rubbing alcohol, then had a bowl of hand grenades and fire crackers for breakfast. "
    story += "After that I went outside and built a chainsaw hand glider out of barbedwire and used it to cut a Siberian tiger in half in space. "
    story += "Then I barbecued it on the sun, and after I ate his tiger ribs I scalped him. "
    story += "Then I fought a fire demon from the 20th dimension. "
    story += "Then saved a monster truck full of babes, then got massaged by " 
    story += number3 + " Brazilian models while I was sitting on a bean bag made out of kitten fur!' "
    story += name2 + " looks at " + name1 + " in awe and says, 'Ugh. I guess you win.' " 
    story += name3 + ", with a shocked look on his face says, 'Yea, big time.' " 
    story += "And that's how guys night went that day."
    
    print 
    print formatString(story, 80, 20)
    print
    
def story3():
    name1 = getWord("Enter a name: ")
    name2 = getWord("Enter another name: ")
    gun = getWord("Enter a the name of a gun: ")
    adjective1 = getWord("Enter a describing word: ")
    store = getWord("Enter the name of a store: ")
    food = getWord("Enter the name of a food: ")
    liquid = getWord("Enter a type of flammable liquid: ")
    story = "One day two friends, " + name1 + " and " + name2 + " were shopping at their local mall. "
    story += name1 + " walks into the store Guns 'N' Shit and grabs a loaded "
    story += gun + " and starts shooting at a bag of chips he had bought. "
    story += name2 + " looks at " + name1 + " and says, 'Seriously, dude, you don't need a " + gun
    story += name1 + " replies, 'Are you kidding?! I've been trying to get this bag of chips open for like a week! This bag was made by SATAN! "
    story += " and he starts shooting the bag of chips. When nothing happens to the bag he looks at " + name2 + " and says, 'See? SEE?! "
    story += "Haaah! I just want some chips!' " 
    story += "Then they here a " + adjective1 + " noise coming from the door. "
    story += name2 + " looks toward the door and says, 'What the-?' And through the glass doors he sees human like creatures bashing on the door. " 
    story += "'Zombies!!!' he cries as they break down the door. " 
    story += name1 + " shoots at the bag of chips and the bullet ricochets off and hits a zombie in the head. "
    story += "He looks at the chips and calmly says, 'Touche bag!' "
    story += name2 + " starts to push " + name1 + " away from the zombies and grabs the bag of chips. "
    story += " They get to the top floor of the mall where they can see the zombies down on the first floor and "
    story += name2 + " says, 'Quick, these dudes want to eat your chips!' "
    story += name1 + " looks at the zombies and says 'Oh, f**k that!' and starts to shoot them in the head. "
    story += "The first one he kills he shouts, 'You dead.' Then as he continues to shoot the zombies he yells, 'Who dead? You dead!' " 
    story += "Then they run into " + store + " and " + name1 + " finds a chainsaw that he decides to use because his gun it out of ammo. "
    story += "He throws the chips on the floor and starts hacking at them with the chainsaw as he shouts, 'Whooo.' "
    story += name2 + " looks at him and says, 'No! Use that on the zombies you retard!' "
    story += name1 + " looks up at him and says, 'Zombies? What zombies?' "  
    story += "And as he continues to try to open the chips, without noticing, he kills " + number1 + " more zombies. "
    story += "He then picks the bag up, and as a zombie tries to bite him he puts the bag in the zombies mouth and pulls. "
    story += "Instead of this ripping the bag open, it rips the zombies head of. When this doesn't work he looks at the bag and says, 'Damn it!' "
    story += "And out of nowhere " + name3 + " comes out and says, 'Hey bros, bros, this is like crazy right?' "
    story += "After a few seconds of silence " + name1 + " lifts up the chainsaw and starts hacking at " + name3 + ". "
    story += name2 + " looks at the corpse and says, 'Um, I don't think that guy was a zombie!' "
    story += "'I know', says " + name1 + ", 'The perfect murder.' " 
    story += "As they were running through " + store + " they noticed a " + food + " where a hoard of zombies was crowding around going crazy for the food. "
    story += "'Oh my god!' says " + name2 + ", 'That must be where the outbreak started! That food is irresistible. "
    story += "Before they knew it the zombies had spotted them, so they ran. They didn't get far until they hit a dead end. "
    story += "So as " + name1 + " continued to fumble with his bag of chips, " + name2 + " noticed a way to stop the hoard. "
    story += "Across the isle from him he noticed a bottle of " + liquid + " right next to the hoard of zombies. " 
    story += "With the shot gun still in hand he shot the bottle of " + liquid + " and it set the whole hoard on fire. "
    story += "With a look of success on his face he shouts, ' F**k Yeah!' "
    story += "Then, due to the fire the sprinkler system came on and put the fire out. "
    story += "In astonishment the two friends watched as the entire hoard rose back to their feet and proceeded towards them. "
    story += name1 + " had still been fumbling with the chips and just as the hoard had rose to their feet the bag of chips popped open. "
    story += "'Oh, sick!' he said with a smile on his face. He had no idea the hoard was still after them. "
    story += name2 + " on the other had knew what was happening and the only words he could muster was, 'Oh f**k!' "
    story += "And that was the last time the two friends were ever seen again."
    
    print
    print formatString(story, 80, 20)
    print
    
def settings():
    txtColor = getColor("Enter Text Color: ")
    bgColor = getColor("Enter Background Color: ")
    if txtColor != bgColor:
        os.system("color " + bgColor + txtColor)
    
def run():
    choice = ""
    while choice != 'Q':
        choice = menu()
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == 'S':
            settings()
        elif choice == 'Q':
            print "Goodbye"
            os.system("color " + bgColor + txtColor)
            raw_input("Press enter to exit")
        else:
            print "Something horrible has occurred...it seems the programmer done goofed."
            
def formatString(s, width, buff):
    ns = ""
    count = 0
    for c in s:
        count += 1
        if c == " ":
            if count >= width - buff:
                ns += "\n"
                count = 0
            else:
                ns += c
        else:
            ns += c
    return ns
    
run()    